$(function () {
    //快捷键回复
    $(document).on("keypress", ".click_key", function (e) {
        if (e.ctrlKey && e.which == 13 || e.which == 10) {
            $(".send_key").click();
        } else if (e.shiftKey && e.which == 13 || e.which == 10) {
            $(".send_key").click();
        }
    });

    //搜索快捷键
    $(".txt_search").keydown(function (e) {
        if (e.which == 13)
            $(".search_btn").click();
    });

    ie_getout();

    //删除专辑
    $(document).on("click", ".js_albumdel", function () {
        var dom = $(this).closest("li");
        del($(dom).attr("data-id"), "album", function () {
            $(dom).fadeOut(function () { $(dom).remove(); });
        });
    });
    //删除文章
    $(document).on("click", ".js_delword", function () {
        var dom = $(this).closest("li");
        del($(dom).attr("data-id"), "word", function () {
            $(dom).fadeOut(function () { $(dom).remove(); });
        });
    });

    //自定义复选框
    $(document).on("click", ".my_check", function () {
        if ($(this).find(".my_ck_remember").hasClass("active"))
            $(this).find(".my_ck_remember").removeClass("active");
        else
            $(this).find(".my_ck_remember").addClass("active");
    });
});
//IE滚
var ie_getout = function () {
    var borwse = navigator.userAgent;
    if (navigator.userAgent.indexOf("MSIE 6.0") > 0 || navigator.userAgent.indexOf("MSIE 7.0") > 0 || navigator.userAgent.indexOf("MSIE 8.0") > 0) {
        if ($(".bowser_out").length == 0)
            $("body").append('<div class="bowser_out">您的浏览器版本太低啦，为了正常使用汉服荟，强烈建议升级浏览器：<a href="http://windows.microsoft.com/zh-cn/internet-explorer/download-ie" target="_blank">升级IE浏览器</a></div>');
    }
}

//动态菜单栏
function trendmore() {
    $(document).bind("click", function (e) {
        var target = $(e.target);
        if (target.closest(".morelist").length == 0 && $(".morelist").length > 0) {
            $(".morelist").hide();
        }
        if (target.hasClass("js_trendMore")) {
            $(target).closest(".details").find(".morelist").show();
        }
    });
}

//幻灯片查询动态图片
function trendpicslide(trendid, index) {
    if ($("#info_img").length > 0) return;
    $.post("/Comm/html.ashx", { action: "PicSlide", trendid: trendid }, function (json) {
        var msg = eval("(" + json + ")");
        $("html").css("overflow", "hidden");
        $("body").append(msg.html);
        slideJS(msg.piclist, index);
    });
}
//幻灯片查询专辑大图
function albumpicslide(albumid, index) {
    if ($("#info_img").length > 0) return;
    $.post("/Comm/html.ashx", { action: "AlbumPicSlide", albumid: albumid }, function (json) {
        var msg = eval("(" + json + ")");
        $("html").css("overflow", "hidden");
        $("body").append(msg.html);
        slideJS(msg.piclist, index);
    });
}

//滚动条距底部距离
function scrollDown() {
    return $(document).height() - $(window).height() - $(window).scrollTop();
}
//通用滚动加载
var ajax_abort = null;
var ban_scroll = false;
var scroll_page = 0;
var scroll_count = 0;
function scrollData(dom, url, data, count, begin2) {    //begin2为是否从第二页开始
    if (begin2)
        scroll_page = 2;
    else
        scroll_page = 1;
    scroll_count = count;
    if (ajax_abort != null) ajax_abort.abort();  //防止刷新频繁，每次重新加载前关闭上一次的Ajax进程
    //首次加载
    ajaxLoad($(dom), url, data);
    //清空之前的滚动事件
    $(window).unbind("scroll");
    //滚动加载
    $(window).scroll(function () {
        if (!ban_scroll && scrollDown() < 100) {
            ban_scroll = true;
            scroll_page++;
            ajaxLoad($(dom), url, data);
        }
    });
}
function ajaxLoad(dom, url, data) {
    if (scroll_page == 1)
        dom.empty();

    data.page = scroll_page;
    data.count = scroll_count;

    dom.append('<div id="infscr-loading"><img src="/App_Image/loading.gif" /></div>');

    ajax_abort = $.ajax({
        type: "get",
        url: url,
        async: true,
        data: data,
        success: function (data) {
            $("#infscr-loading").remove();
            if (data != null && data != "" && ((data.indexOf("class=\"nodata\"") > 0 && scroll_page == 1) || data.indexOf("class=\"nodata\"") == -1)) {
                dom.append(data);
                ban_scroll = false;
            }
        }
    });
}

//幻灯片查询JS代码
function slideJS(piclist, i) {
    var index = i;
    $(".zoompic").width($(window).width());
    $(window).resize(function () {
        $(".zoompic").height("auto");
        $(".zoompic").width($(window).width());
    });
    upnextimg(piclist[index]);

    $(".zoompic_left").click(function () {
        index--;
        if (0 > index)
        { showover(); index++; return; }

        upnextimg(piclist[index]);
    });
    $(".zoompic_right").click(function () {
        index++;
        if (piclist.length < (index + 1))
        { showover(); index--; return; }

        upnextimg(piclist[index]);
    });
    $(".zoompic_img").click(function () {
        $(".zoompic_right").click();
    });

    $(".info_close").click(function () {
        $("html").css("overflow", "auto");
        $(document).unbind("keydown");
        $("#info_img").remove();
    });
    //左右按键翻图
    $(document).keydown(function () {
        var key = event.which;
        if (key == 39)
            $(".zoompic_right").click();
        else if (key == 37)
            $(".zoompic_left").click();
    });
}

function upnextimg(pic) {
    $(".zoompic").height($(window).height());
    $(".zoomover").hide();
    $(".zoompic_img").hide();
    $(".zoompic_img").attr({ "src": pic + "_1100.jpg" });
    $(".zoompic_img").load(function () {
        var this_0 = this;
        $(".zoompic").height("auto");
        $(this_0).show();
        $(this_0).css("height", "auto");
        if ($(this_0).height() >= $(this_0).width() * 2) {
            $(".zoombox").css("overflow", "auto");
            $(".info_close").css("right", "20px");
            $(this_0).css("margin", "0px auto");
        } else {
            if ($(this_0).height() > $(window).height())
                $(this_0).height($(window).height());
            $(".zoombox").css("overflow", "hidden");
            $(".info_close").css("right", "0px");
            $(this_0).css("margin", ($(window).height() - $(this_0).height()) / 2 + "px auto");
        }
    });
}
function showover() {
    $(".zoomover").fadeIn(function () {
        setTimeout(function () {
            $(".zoomover").fadeOut(1000);
        }, 1000);
    });
}
//验证文件名后缀
function CheckFileType(filename) {
    if (filename.indexOf('.') == -1)
        return false;

    var suffix = filename.substring(filename.lastIndexOf('.') + 1).toLocaleLowerCase();

    if (suffix == "jpg" || suffix == "jpeg" || suffix == "png" || suffix == "gif")
        return true;
    else
        return false;
}
//举报弹窗
function report(objecttype, objectid, userid) {
    $.post("/Comm/html.ashx", { action: "Report", objecttype: objecttype, objectid: objectid, userid: userid }, function (data) {
        form_show(400, 310, "举报", data);
    });
}
//提交举报
function insreport(objecttype, objectid, userid) {
    var sel = $(".rad_rep_sel:checked").val();
    var desc = $.trim($(".rep_desc").val());

    if (sel == null || sel == "") {
        $.alert("请选择举报类型", "warn"); return;
    }

    $.post("/Comm/system.ashx", { action: "InsReport", objecttype: objecttype, objectid: objectid, userid: userid, desc: "【" + sel + "】" + desc }, function (data) {
        if (data == "0") {
            $.alert("提交成功", "right");
            setTimeout(form_close, 500);
        }
        else
            $.alert(data, "error");
    });
}
//视频
function openvideo(url) {
    if (!url) return '';
    url = $.trim(url)
        .replace(/v\.youku\.com\/v_show\/id_([\w\-=]+)\.html\S*/i, 'player.youku.com/player.php/sid/$1/v.swf')
        .replace(/(www\.)?youtube\.com\/watch\?v=([\w\-]+)/i, "www.youtube.com/v/$2")
        .replace(/youtu.be\/(\w+)$/i, "www.youtube.com/v/$1")
        .replace(/v\.ku6\.com\/.+\/([\w\.]+)\.html.*$/i, "player.ku6.com/refer/$1/v.swf")
        .replace(/www\.56\.com\/u\d+\/v_([\w\-]+)\.html/i, "player.56.com/v_$1.swf")
        .replace(/www.56.com\/w\d+\/play_album\-aid\-\d+_vid\-([^.]+)\.html/i, "player.56.com/v_$1.swf")
        .replace(/v\.pps\.tv\/play_([\w]+)\.html.*$/i, "player.pps.tv/player/sid/$1/v.swf")
        .replace(/www\.letv\.com\/ptv\/vplay\/([\d]+)\.html.*$/i, "i7.imgs.letv.com/player/swfPlayer.swf?id=$1&autoplay=0")
        .replace(/www\.tudou\.com\/programs\/view\/([\w\-]+)\/?/i, "www.tudou.com/v/$1")
        .replace(/www\.tudou\.com\/listplay\/([\w\-]+)\/([\w\-]+).html\/?/i, "www.tudou.com/v/$2/v.swf")
        .replace(/v\.qq\.com\/cover\/[\w]+\/[\w]+\/([\w]+)\.html/i, "static.video.qq.com/TPout.swf?vid=$1")
        .replace(/v\.qq\.com\/.+[\?\&]vid=([^&]+).*$/i, "static.video.qq.com/TPout.swf?vid=$1")
        .replace(/my\.tv\.sohu\.com\/[\w]+\/[\d]+\/([\d]+)\.shtml.*$/i, "share.vrs.sohu.com/my/v.swf&id=$1")
        .replace(/www.bilibili.com\/video\/av([\d]+)\S*/i, "static.hdslb.com/miniloader.swf?aid=$1")
        .replace(/www.acfun.tv\/v\/ac([\d]+)/i, "cdn.aixifan.com/player/ACFlashPlayer.out.swf?type=page&url=http://www.acfun.tv/v/ac$1")
        .replace(/acfun.tudou.tv\/v\/ac([\d]+)/i, "cdn.aixifan.com/player/ACFlashPlayer.out.swf?type=page&url=http://www.acfun.tv/v/ac$1");

    $(".videoplay").remove();
    $("body").append("<div class=\"videoplay\" style=\"position:fixed;top:0px; left:0px;width:100%;height:100%;background:rgba(0,0,0,0.8);z-index:1000;\"><embed style=\"position:fixed;top:50%; left:50%; margin:-207px 0 0 -272px;z-index:1001;\" height=\"415\" width=\"544\" type=\"application/x-shockwave-flash\" allowscriptaccess=\"always\" allowfullscreen=\"true\" wmode=\"opaque\" src=\"" + url + "\"></embed><span style=\"position: absolute;top: 0px;right: 0px;width: 52px;height: 48px;background: url(/App_Image/png_icons.png) no-repeat -61px 0;cursor: pointer;display: block;z-index: 1001;\" onclick=\"javascript:$('.videoplay').remove()\"></span></div>");
}
//添加收藏
function inssave(dom, objectid, objecttype) {
    $.post("/Comm/save.ashx", { action: "InsSave", objecttype: objecttype, objectid: objectid }, function (data) {
        if (data == "0") {
            $.alert("收藏成功", "right");
            $(dom).addClass("btn_gray").html("<i class=\"ico_save\"></i>已藏");
            $(dom).attr("onclick", "delsave(this," + objectid + ",'" + objecttype + "')");
        }
        else
            $.alert(data, "error");
    });
}
//取消收藏
function delsave(dom, objectid, objecttype) {
    $.post("/Comm/save.ashx", { action: "DelSave", objecttype: objecttype, objectid: objectid }, function (data) {
        if (data == "0") {
            $.alert("取消收藏成功", "right");
            $(dom).removeClass("btn_gray").html("<i class=\"ico_save\"></i>收藏");
            $(dom).attr("onclick", "inssave(this," + objectid + ",'" + objecttype + "')");
        }
        else
            $.alert(data, "error");
    });
}

//清空表单
function clearForm(dom) {
    $(dom).find("input[type=text]").val("");
    $(dom).find("input[type=checkbox]").removeAttr("checked");
    $(dom).find("select").val("0");
    $(dom).find("textarea").val("");
    $(dom).find("img").removeAttr("data-src").attr("src", "/App_Image/pic_null.png");
}

//加载省市列表
function loadaddress(parentid) {
    $.ajax({
        type: "post",
        url: "/Comm/system.ashx",
        async: true,
        data: { action: "LoadAddress", parentid: parentid },
        success: function (data) {
            if (parentid == 0)
                $(".sel_add1").html(data);
            else
                $(".sel_add2").html(data);
        }
    });
}
//脚部登录框
function footlogin() {
    if ($('.foot_login').length == 0) return;
    $(window).scroll(function () {
        if ($(window).scrollTop() >= 800) {
            if ($('.foot_login').attr("data-state") == "1") return;
            $('.foot_login').animate({ "bottom": "0px" }, function () {
                $('.foot_login').attr("data-state", "1");
            });
        } else {
            if ($('.foot_login').attr("data-state") == "0") return;
            $('.foot_login').animate({ "bottom": "-100px" }, function () {
                $('.foot_login').attr("data-state", "0");
            });
        }
    });
}

//回顶部//意见反馈
function totop() {
    $(window).scroll(function () {
        if ($(window).scrollTop() >= 800) {
            $('#reg_top').fadeIn(400);
        } else {
            $('#reg_top').fadeOut(400);
        }
    });
    $("#reg_top .top").click(function () {
        $('html,body').animate({ scrollTop: "0px" }, 500);
    });

    $("#reg_top .opinion").click(function () {
        form_show(400, 176, "意见反馈", '<textarea class="txt_option" style="width: 334px; border: 1px #ccc solid; padding: 2px; height: 100px;overflow:auto "></textarea><input type="button" onclick="insoption()" class="btn_red p4 fr mt10" value="提交" />');

        $(document).on("keypress", ".txt_option", function (e) {
            if (e.ctrlKey && e.which == 13 || e.which == 10) {
                insoption();
            } else if (e.shiftKey && e.which == 13 || e.which == 10) {
                insoption();
            }
        });
    });
}

//提交意见反馈
function insoption() {
    var content = $.trim($(".txt_option").val());
    if (content == null || content == "")
        $.alert("内容不能为空哦~", "warn");
    else if (getLen(content) > 5000)
        $.alert("内容太长，请缩减到2500字以内", "warn");
    else {
        $.post("/Comm/system.ashx", { action: "InsOption", content: content }, function (data) {
            if (data == "0") {
                $.alert("提交成功，感谢您的反馈", "right");
                $(".txt_option").val("");
            }
            else
                $.alert(data, "error");
        });
    }
}

//检测是否登录
function checklogin() {
    return $(".hd_login_userid").val() > 0;
}

//登录窗弹出
function showLogin(from) {
    $.post("/Comm/html.ashx", { action: "LoginHtml", from: from }, function (data) { form_show(540, 210, "登录", data); login(); });
}

//弹出层
function form_show(width, height, title, html) {
    if ($(".form_show_bg").length > 0 || $(".form_show").length > 0)
        return;

    height = height + 70;
    var htmls = "<div class=\"form_show_bg\"></div><div style=\"width:" + width + "px;height:" + height + "px;margin:-" + (height / 2) + "px 0 0 -" + (width / 2) + "px\" class=\"form_show\">";
    if (title != null)
        htmls += "<div class=\"div_top\"><span>" + title + "</span><i class=\"div_close\"></i></div>";
    htmls += "<div class=\"div_content\">" + html + "</div></div>";

    $("body").append(htmls);
    $(".form_show_bg").animate({ opacity: "0.3" }, "normal", function () { $(".form_show").show(); });

    $(document).on("click", ".div_close", form_close);
}
//关闭弹出层
function form_close() {
    $(".form_show_bg,.form_show").animate({ opacity: "0" }, "normal", function () { $(this).remove(); });
}
//关注/取关荟吧样式处理
function fwhuibadom(dom, huibaid, follow) {
    followhuiba(huibaid, follow, function () {
        if (follow) {
            $(dom).attr("onclick", "fwhuibadom(this," + huibaid + ",false)");
            $(dom).addClass("btn_gray");
            $(dom).html("已关注");
        } else {
            $(dom).attr("onclick", "fwhuibadom(this," + huibaid + ",true)");
            $(dom).removeClass("btn_gray").addClass("btn_red");
            $(dom).html("关注");
        }
    });
}
//关注/取关荟吧
function followhuiba(huibaid, follow, callback) {
    $.post("/comm/huiba.ashx", { action: "FollowHuiba", huibaid: huibaid, follow: follow }, function (data) {
        if (data == "0") {
            if (callback != null && $.isFunction(callback))
                callback();
        } else if (data == "1")
            showLogin();
        else
            $.alert(data, "error");
    });
}

//删除
function del(objectid, objecttype, callback) {
    $.confirm("确定要删除吗，(┯_┯)", function () {  //删除动态
        if (objecttype == "trend") {
            $.post("/Comm/trend.ashx", { action: "delTrend", id: objectid }, function (data) {
                if (data == "0") {
                    if (callback != null && $.isFunction(callback))
                        callback(objectid);
                } else
                    $.alert(data, "error");
            });
        }
        else if (objecttype == "letter") { //删除私信
            $.post("/Comm/letter.ashx", { action: "delLetter", id: objectid }, function (data) {
                if (data == "0") {
                    if (callback != null && $.isFunction(callback))
                        callback(objectid);
                } else
                    $.alert(data, "error");
            });
        }
        else if (objecttype == "album") { //删除摄影
            $.post("/Comm/album.ashx", { action: "DelAlbum", id: objectid }, function (data) {
                if (data == "0") {
                    if (callback != null && $.isFunction(callback))
                        callback(objectid);
                } else
                    $.alert(data, "error");
            });
        }
        else if (objecttype == "word") { //删除文章
            $.post("/Comm/word.ashx", { action: "DelWord", id: objectid }, function (data) {
                if (data == "0") {
                    if (callback != null && $.isFunction(callback))
                        callback(objectid);
                } else if (data == "1")
                    showLogin();
                else
                    $.alert(data, "error");
            });
        }
    });
}
//分享到微信
function shareWeixin(url) {
    form_show(240, 210, "分享到微信", "<div class=\"twocode_box\"><p class=\"twocode_loading\">正在生成二维码</p></div>");
    $.ajax({
        type: "post",
        async: true,
        url: "/comm/html.ashx",
        data: { action: "shareWeixin", url: url },
        success: function (data) {
            $(".twocode_box").html(data);
            $(".twocode_loading").hide();
        }
    });
}

//选择表情
//var loadface = 0;
function addface(dom, txtdom) {
    if ($(".shuo_face").is(":visible"))
        $(".shuo_face").hide()
    else {
        var top = $(dom).offset().top;
        var left = $(dom).offset().left;
        $(".shuo_face").css({ "top": (top + 30) + "px", "left": (left - 13) + "px" }).show();
    }

    // if (loadface == 0) {
    //给表情列表添加不失去光标事件，为了便于在文本中间插入表情时光标不变
    $(".face_midd").mousedown(function () { return false; });

    $(".shuo_face .face_midd").click(function () {
        var facecon = "[" + $(this).find("img").attr("data-name") + "]";
        if ($(txtdom).is(":focus")) {
            innerCon($(txtdom), facecon); //在光标处插入内容
        } else {
            $(txtdom).val($(txtdom).val() + facecon);
        }
        $(".shuo_face").hide();
        $(".shuo_face .face_midd").unbind("click");
    });
    //关闭弹出表情面板
    $(document).on("click", document, function (event) {
        if ($(event.target).parents(".shuo_face").length == 0 && $(event.target).attr("data-face") != "1") {
            $(".shuo_face").hide();
        }
    });
    // loadface = 1;
    //  }
}

//上传单张图片【已作废】
function upload_one(callback_start, callback_ok) {
    $(".up_file").change(function () {
        if (callback_start != null && $.isFunction(callback_start))
            callback_start();

        var imgoldsrc = $(".upload_pic img").attr("src");

        $(".upload_pic i").css("display", "inline-block");
        $(".upload_pic img").attr({ "src": "/App_Image/one_upload_1.png", "data-state": "0" });
        $("#file_form").ajaxSubmit({
            type: "POST",
            url: "/Comm/upload.ashx",
            dataType: "text",
            async: true,
            beforeSend: function () {
            },
            success: function (json) {
                json = json.replace(/<[^>]+>/g, "");
                var msg = eval("(" + json + ")");
                if (msg.state == "0") {
                    $(".upload_pic img").attr({ "src": msg.url, "data-src": msg.saveurl, "data-state": "1" });
                    if (callback_ok != null && $.isFunction(callback_ok))
                        callback_ok(msg.url);
                }
                else {
                    $(".upload_pic img").attr({ "src": imgoldsrc, "data-state": "1" });
                }
                $(".upload_pic i").css("display", "none");
            }
        });
        return false;
    });
    $(".upload_pic").click(function () {
        $(".up_file").click();
    });
}

//上传单张图片，自定义对象【已作废】
function upload(dom, formdom) {
    $(formdom).find(".up_file").change(function () {
        $(dom).closest(".upload_pic").find("i").css("display", "inline-block");
        $(dom).closest(".upload_pic").find("img").attr({ "src": "/App_Image/one_upload_1.png", "data-state": "0" });
        $(formdom).ajaxSubmit({
            type: "POST",
            url: "/Comm/upload.ashx",
            dataType: "text",
            async: true,
            beforeSend: function () {
            },
            success: function (json) {
                json = json.replace(/<[^>]+>/g, "");
                var msg = eval("(" + json + ")");
                if (msg.state == "0") {
                    $(dom).closest(".upload_pic").find("img").attr({ "src": msg.url, "data-src": msg.saveurl, "data-state": "1" });
                }
                else {
                }
                $(dom).closest(".upload_pic").find("i").css("display", "none");
            }
        });
        return false;
    });
    $(formdom).find(".up_file").click();
}

//上传单张图片，写死控件【直接传到又拍云】
function uploadimagetemp(imghz) {
    uploadimage(".upload_pic .upload", "", ".upload_pic img", imghz);
}
//上传单张图片【直接传到又拍云】
function uploadimage(dombtn, tag, imgdom, imghz, callback) {
    dombtntext = $(dombtn).html();

    var inputid = "fileDatas" + tag;
    if ($("#" + inputid).length == 0) {
        $("body").append('<input type="file" id="' + inputid + '" name="file" accept="image/gif,image/jpeg,image/png" style="position: absolute; top: -1000px; left: -1000px; opacity: 0;" multiple="multiple" />');
    }
    console.log(dombtn);
    $(dombtn).click(function () {
        $("#" + inputid).click();
    });

    $("#" + inputid).change(function () {
        var file = $("#" + inputid).get(0).files[0];
        if (file == null) return;

        btndis($(dombtn), "正在上传");

        $.get("/comm/upload.ashx", { action: "GetImageAuthorization", filesize: file.size, filetype: file.type }, function (data) {
            var msg = eval("(" + data + ")");
            if (msg.state != "0") {
                $.alert(msg.state, "error");
                btnopen($(dombtn), dombtntext);
            }
            else {
                var formData = new FormData();
                formData.append("policy", msg.policy);
                formData.append("authorization", msg.authorization);
                formData.append("file", file);
                $.ajax({
                    url: msg.url,
                    type: "POST",
                    data: formData,
                    contentType: false,
                    processData: false,
                    xhr: xhrOnProgress(function (e) {
                        var percent = Math.round(e.loaded * 100 / e.total);

                        btndis($(dombtn), percent + "%");
                    }),
                    success: function (data, textStatus, xhr) {
                        data = data.replace(new RegExp("-", "g"), "_");
                        var msg2 = eval("(" + data + ")");

                        msg2.url = msg.pichost + msg2.url;

                        //自定义图片版本
                        var showurl = msg2.url;
                        if (imghz != null && imghz != "")
                            showurl = showurl + imghz;
                        else
                            showurl = showurl + "_200x200.jpg"

                        $(imgdom).attr({ "src": showurl, "data-src": msg2.url, "data-width": msg2.image_width, "data-height": msg2.image_height, "data-size": msg2.file_size });

                        btnopen($(dombtn), dombtntext);

                        if (callback != null && $.isFunction(callback))
                            callback(msg2);
                    },
                    error: function (xhr) {
                        console.log(xhr);
                        //状态还原
                        btnopen($(dombtn), dombtntext);
                    }
                });
            }
        });
    });
}

//上传批量图片【直接传到又拍云】
var file_index = 0; //当前选择的图片列表下标
var file_count = 0; //当前选择的图片数量
var upload_index = 0; //所有上传的图片列表下标，用于生成唯一id
var dombtntext = "";
function uploadimages(dombtn, BeginCallback, OneprogressCallback, OneSuccessCallback, SuccessCallback) {
    dombtntext = $(dombtn).html();
    var inputid = "fileDatas";
    if ($("#" + inputid).length == 0) {
        $("body").append('<input type="file" id="' + inputid + '" name="file" accept="image/gif,image/jpeg,image/png" style="position: absolute; top: -1000px; left: -1000px; opacity: 0;" multiple="multiple" />');
    }
    $(dombtn).click(function () {
        $("#" + inputid).click();
    });
    $("#" + inputid).change(function () {
        var files = $("#" + inputid).get(0).files;
        if (files == null || files.length == 0) return;

        btndis($(dombtn), "正在上传");

        file_count = files.length;
        file_index = 0;

        if (BeginCallback != null && $.isFunction(BeginCallback)) {
            //通过回调函数中断上传
            if (BeginCallback(file_count, upload_index) == false) {
                btnopen($(dombtn), dombtntext);
                return;
            }
        }

        uploadimagebase(dombtn, inputid, files, OneprogressCallback, OneSuccessCallback, SuccessCallback);
    });
}
function uploadimagebase(dombtn, inputid, files, OneprogressCallback, OneSuccessCallback, SuccessCallback) {

    var file = files[file_index];

    $.get("/comm/upload.ashx", { action: "GetImageAuthorization", filesize: file.size, filetype: file.type }, function (data) {
        var msg = eval("(" + data + ")");
        if (msg.state != "0") {
            $.alert(msg.state, "error");
            btnopen($(dombtn), dombtntext);
        }
        else {
            var formData = new FormData();
            formData.append("policy", msg.policy);
            formData.append("authorization", msg.authorization);
            formData.append("file", file);
            $.ajax({
                url: msg.url,
                type: "POST",
                data: formData,
                contentType: false,
                processData: false,
                xhr: xhrOnProgress(function (e) {
                    var percent = Math.round(e.loaded * 100 / e.total);

                    if (OneprogressCallback != null && $.isFunction(OneprogressCallback))
                        OneprogressCallback(upload_index, percent);
                }),
                success: function (data, textStatus, xhr) {
                    data = data.replace(new RegExp("-", "g"), "_");
                    var msg2 = eval("(" + data + ")");

                    msg2.url = msg.pichost + msg2.url;
                    console.log(msg2);
                    if (OneSuccessCallback != null && $.isFunction(OneSuccessCallback))
                        OneSuccessCallback(upload_index, msg2);

                    file_index++; upload_index++;
                    if (file_index < file_count) {
                        uploadimagebase(dombtn, inputid, files, OneprogressCallback, OneSuccessCallback, SuccessCallback);
                    } else {
                        //当前选择图片全部上传完成
                        btnopen($(dombtn), dombtntext);
                        if (SuccessCallback != null && $.isFunction(SuccessCallback))
                            SuccessCallback();
                    }
                },
                error: function (xhr) {
                    console.log(xhr);
                    //状态还原
                    btnopen($(dombtn), dombtntext);
                }
            });
        }
    });
}

//上传视频
function uploadvideo(dombtn, index, progressCallback, successCallback) {

    var inputid = "fileData" + index;
    if ($("#" + inputid).length == 0) {
        $("body").append('<input type="file" id="' + inputid + '" name="file" accept="video/mp4,video/flv" style="position: absolute; top: -1000px; left: -1000px; opacity: 0;" />');
    }
    $(dombtn).click(function () {
        $("#" + inputid).click();
    });
    $("#" + inputid).change(function () {
        var file = $("#" + inputid).get(0).files[0];
        if (file == null) return;

        btndis($(dombtn), "正在上传");
        $.get("/comm/video.ashx", { action: "GetVideoAuthorization", filesize: file.size, filetype: file.type }, function (data) {
            console.log(data);
            var msg = eval("(" + data + ")");
            if (msg.state != "0") {
                $.alert(msg.state, "error");
                btnopen($(dombtn), "选择视频");
            }
            else {
                var formData = new FormData();
                formData.append("policy", msg.policy);
                formData.append("authorization", msg.authorization);
                formData.append("file", file);
                $.ajax({
                    url: msg.url,
                    type: "POST",
                    data: formData,
                    contentType: false,
                    processData: false,
                    xhr: xhrOnProgress(function (e) {
                        var percent = Math.round(e.loaded * 100 / e.total);

                        if (progressCallback != null && $.isFunction(progressCallback))
                            progressCallback(percent);
                    }),
                    success: function (data, textStatus, xhr) {
                        var msg2 = eval("(" + data + ")");

                        $.get("/comm/video.ashx", { action: "GetVideoMeta", source: msg2.url }, function (data) {
                            console.log(data);
                            var msg3 = eval("(" + data + ")");

                            if (msg3.state == "0") {
                                if (successCallback != null && $.isFunction(successCallback))
                                    successCallback(msg3);
                            } else
                                $.alert(msg3.state, "error");

                            //状态还原
                            btnopen($(dombtn), "选择视频");
                        });
                    },
                    error: function (xhr) {
                        console.log(xhr);
                        //状态还原
                        btnopen($(dombtn), "选择视频");
                    }
                });
            }
        });
    });
}
//ajax请求进度条
var xhrOnProgress = function (fun) {
    xhrOnProgress.onprogress = fun;
    return function () {
        var xhr = $.ajaxSettings.xhr();
        if (typeof xhrOnProgress.onprogress !== 'function') {
            return xhr;
        }
        if (xhrOnProgress.onprogress && xhr.upload) {
            xhr.upload.onprogress = xhrOnProgress.onprogress;
        }
        return xhr;
    }
}

//获取验证码
function getcode(dom, updpwd) {
    var phone = $(".txt_phone").val();
    var time_0 = null;

    if (phone == null || phone == "")
    { $.alert("请填写手机", "warn"); return; }
    if (!checkphone(phone))
    { $.alert("手机格式不正确", "warn"); return; }

    $.post("/Comm/user.ashx", { action: "GetPhoneCode", phone: phone, updpwd: updpwd }, function (data) {
        if (data == "0") {
            $(dom).addClass("btn_gray");
            clearInterval(time_0);

            var t = 59;
            btndis($(dom), t + "秒后重获");
            time_0 = setInterval(function () {
                t--;
                btndis($(dom), t + "秒后重获");
                if (t == 0) {
                    clearInterval(time_0);
                    btnopen($(dom), "获取验证码");
                }
            }, 1000);
        }
        else
            $.alert(data, "error");
    });
}

//验证邮箱格式
function checkemail(str) {
    return /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1,2})$/.test(str)
}
//验证手机格式
function checkphone(str) {
    return /^1[1-9]\d{9}$/.test(str);
}
//验证QQ格式
function checkqq(str) {
    return /^[1-9][0-9]{4,13}$/.test(str);
}
//验证Url格式
function checkurl(str) {
    return str.indexOf("http://") == 0 || str.indexOf("https://") == 0;
}
//验证帐号
function checkuser(str)
{ return /^[a-zA-Z0-9_]+[a-zA-Z0-9_]+[a-zA-Z0-9_]$/.test(str); }
//验证昵称
function checknick(str)
{ return /^([\u4e00-\u9fa5]|[\w]|[_])+$/.test(str); }

//弹出私信窗
function letterform(unick, userid) {
    if (!checklogin()) { showLogin(); return; }

    form_show(400, 176, "与" + unick + "的私信", '<textarea data-userid="' + userid + '" class="txt_letter_content" style="width: 334px; border: 1px #ccc solid; padding: 2px; height: 100px;overflow:auto "></textarea><input type="button" onclick="insletter_begin(this)" class="btn_red p4 fr mt10" value="发送" />');
    $(document).on("keypress", ".txt_letter_content", function (e) {
        if (e.ctrlKey && e.which == 13 || e.which == 10) {
            insletter_begin($(this).parent().find("input[type=button]"));
        } else if (e.shiftKey && e.which == 13 || e.which == 10) {
            insletter_begin($(this).parent().find("input[type=button]"));
        }
    });
}
//获取私信内容
function insletter_begin(dom) {
    var touserid = $(".txt_letter_content").attr("data-userid");
    var content = $(".txt_letter_content").val();
    insletter(touserid, content, dom, insletter_callback);
}
//私信发送回调函数
function insletter_callback(dom, id) {
    form_close();
}

//关注好友
function insatte(atteuserid, dom) {
    if ($(dom).closest(".morelist").length > 0) {
        $(dom).html("已关注");
        $(dom).closest(".morelist").hide();
    } else {
        $(dom).addClass("btn_atte_c").removeClass("btn_atte");
        $(dom).html("<i></i>已关注");
    }
    $.post("/Comm/user.ashx", { action: "InsAtte", atteuserid: atteuserid, atte: true }, function (data) {
        if (data == "0") {
            $.alert("关注成功", "right");
            $(dom).addClass("js_delAtte").removeClass("js_insAtte");
        } else if (data == "1")
            showLogin();
        else {
            $(dom).addClass("js_insAtte").removeClass("js_delAtte");
            $.alert(data, "error");
        }
    });
}
//取消关注
function delatte(atteuserid, dom) {
    if ($(dom).closest(".morelist").length > 0) {
        $(dom).html("关注");
        $(dom).closest(".morelist").hide();
    } else {
        $(dom).addClass("btn_atte").removeClass("btn_atte_c");
        $(dom).html("<i></i>关注");
    }

    $.post("/Comm/user.ashx", { action: "InsAtte", atteuserid: atteuserid, atte: false }, function (data) {
        if (data == "0") {
            $.alert("取消关注成功", "right");
            $(dom).addClass("js_insAtte").removeClass("js_delAtte");
        } else if (data == "1")
            showLogin();
        else {
            $(dom).addClass("js_delAtte").removeClass("js_insAtte");
            $.alert(data, "error");
        }
    });
}

//系统繁忙提示
function timeoutShow(dom) {
    $(dom).find(".list_loading").remove();
    $(dom).append("<li class=\"list_loading\">系统繁忙，点击<a class=\"font_red\" onclick=\"loadTrend()\">重新加载</a></li>");
}
//加载中等待条
function loading(dom) {
    $(dom).find(".list_loading").remove();
    $(dom).append("<li class=\"list_loading\"><i></i></li>");
}
//清空加载条和系统繁忙
function clearLoad(dom) {
    $(dom).find(".list_loading").remove();
}

//评论
function inscomm(objectid, objecttype, content, parentid, dom, callback) {
    if (content == null || content == "")
    { $.alert("请填写评论内容", "warn"); return; }
    var domcon = $(dom).val();
    btndis($(dom), "正在发表");
    $.post("/Comm/comment.ashx", { action: "InsComment", objectid: objectid, objecttype: objecttype, content: content, parentid: parentid }, function (json) {
        var msg = eval("(" + json + ")");
        if (msg.state == "0") {
            if (msg.hanbi == 0)
                $.alert("发表成功", "right");
            else
                $.alert("今日已评论5次，获得" + msg.hanbi + "汉币奖励", "right");
            btnopen($(dom), domcon);
            if (callback != null && $.isFunction(callback))
                callback(msg.id);
        } else if (msg.state == "1")
            showLogin();
        else {
            btnopen($(dom), "发表");
            $.alert(msg.state, "error");
        }
    });
}

//删除评论
function delcomm(id, dom) {
    $.confirm("确定要删除？", function () {
        $.post("/Comm/comment.ashx", { action: "DelComment", id: id }, function (data) {
            if (data == "0") {
                $.alert("删除成功", "right");
                $(dom).fadeOut(function () { $(dom).remove(); });
            }
            else
                $.alert(data, "error");
        });
    });
}

//点赞
function instop(objectid, objecttype, dom, callback) {
    $.post("/Comm/comment.ashx", { action: "InsTop", objectid: objectid, objecttype: objecttype }, function (json) {
        var msg = eval("(" + json + ")");
        if (msg.state == "0") {
            $(dom).removeAttr("onclick");
            if (callback != null && $.isFunction(callback))
                callback(dom);
        } else if (msg.state == "1")
            showLogin();
        else {
            $.alert(msg.state, "error");
        }
    });
}

//私信
function insletter(touserid, content, dom, callback) {
    btndis($(dom), "正在发送");
    $.post("/Comm/letter.ashx", { action: "InsLetter", touserid: touserid, content: content }, function (json) {
        var msg = eval("(" + json + ")");
        if (msg.state == "0") {
            $.alert("发送成功", "right");
            btnopen($(dom), "发送");
            if (callback != null && $.isFunction(callback))
                callback(dom, msg.id);
        } else if (msg.state == "1")
            showLogin();
        else {
            btnopen($(dom), "发送");
            $.alert(msg.state, "error");
        }
    });
}

//禁用按钮
function btndis(dom) {
    if (dom[0].tagName == "INPUT" || dom[0].tagName == "BUTTON")
        dom.attr("disabled", "disabled").addClass("btn_gray");
    else
        dom.attr("data-onclick", dom.attr("onclick")).removeAttr("onclick").addClass("font_gray");

    if (dom[0].tagName == "INPUT")
        dom.val("正在提交")
    else
        dom.html("正在提交");
}
function btndis(dom, word) {
    if (dom[0].tagName == "INPUT" || dom[0].tagName == "BUTTON")
        dom.attr("disabled", "disabled").addClass("btn_gray");
    else
        dom.attr("data-onclick", dom.attr("onclick")).removeAttr("onclick").addClass("font_gray");
    
    if (dom[0].tagName == "INPUT")
        dom.val(word)
    else
        dom.html(word);
}
function btnopen(dom, word) {
    if (dom[0].tagName == "INPUT" || dom[0].tagName == "BUTTON")
        dom.removeAttr("disabled").removeClass("btn_gray");
    else
        dom.attr("onclick", dom.attr("data-onclick")).removeAttr("data-onclick").removeClass("font_gray");
    
    if (dom[0].tagName == "INPUT")
        dom.val(word)
    else
        dom.html(word);
}

//过滤Html标签
function setContent(str) {
    str = str.replace(/<\/?[^>]*>/g, ''); //去除HTML tag
    str.value = str.replace(/[ | ]*\n/g, '\n'); //去除行尾空白
    str = str.replace(/\n[\s| | ]*\r/g, '\n'); //去除多余空行
    return str;
}
//HTML编码
function HTMLEncode(str) {
    //return str ? str.replace(reg || /[&<">'](?:(amp|lt|quot|gt|#39|nbsp);)?/g, function (a, b) {
    //    if (b) {
    //        return a;
    //    } else {
    //        return {
    //            '<': '&lt;',
    //            '&': '&amp;',
    //            '"': '&quot;',
    //            '>': '&gt;',
    //            "'": '',
    //            '\n':"<br>"
    //        }[a]
    //    }
    //}) : '';

    var s = "";
    if (str == null || str.length == 0) return "";
    s = str.replace(/&/g, "&amp;");
    s = s.replace(/</g, "&lt;");
    s = s.replace(/>/g, "&gt;");
    //s = s.replace(/ /g, "&nbsp;");
    s = s.replace(/\'/g, "&#39;");
    s = s.replace(/\"/g, "&quot;");
    s = s.replace(/\n/g, "<br>");
    return s;
}

//HTML解码
function HTMLDecode(str) {
    return str ? str.replace(/&((g|l|quo)t|amp|#39);/g, function (m) {
        return {
            '&lt;': '<',
            '&amp;': '&',
            '&quot;': '"',
            '&gt;': '>',
            '&#39;': "'"
        }[m]
    }) : '';
}

//计算字符长度【中文算两个】
function getLen(str) {
    var totallength = 0;
    for (var i = 0; i < str.length; i++) {
        var intCode = str.charCodeAt(i);
        if (intCode >= 0 && intCode <= 128 && intCode != 33 && intCode != 64 && intCode != 35 && intCode != 36 && intCode != 37 && intCode != 94 && intCode != 38 && intCode != 42 && intCode != 40 && intCode != 41 && intCode != 95 && intCode != 43) {
            totallength = totallength + 1; //非中文单个字符长度加 1
        }
        else {
            totallength = totallength + 2; //中文字符长度则加 2
        }
    }
    return totallength;
}

//帐号密码登录
function login(rallback) {
    $(".login_check").click(function () {
        if ($(".ck_remember").attr("checked") != "checked")
            $(".ck_remember").css({ "background-position": "-365px -12px" }).attr("checked", "checked");
        else
            $(".ck_remember").css({ "background-position": "-384px -12px" }).removeAttr("checked");
    });
    $(".login_btn").click(function () {
        var username = $(".txt_username").val();
        var password = $(".txt_password").val();
        var code = false;
        var dom = $(this);
        if ($(".ck_remember") != null && $(".ck_remember").attr("checked") == "checked") code = true;

        if ($(".hd_nopwd") != null && $(".hd_nopwd").val() == "1") {
            $.confirm("是否记住密码", function () {
                login_helper(dom, username, password, true, rallback);
            }, function () {
                login_helper(dom, username, password, false, rallback);
            });
        } else {
            login_helper(dom, username, password, code, rallback);
        }

    });
    $(".txt_password").keydown(function (e) {
        if (e.which == 13)
            $(".login_btn").click();
    });
}

function login_helper(dom, username, password, code, rallback) {
    if (username == null || username == "")
        $.alert("帐号不能为空", "warn");
    else if (password == null || password == "")
        $.alert("密码不能为空", "warn");
    else {
        btndis(dom, "正在登录...");
        $.post("/Comm/user.ashx", { action: "Login", username: username, password: password, code: code }, function (data) {
            if (data == "0") {
                if (rallback != null && $.isFunction(rallback))
                    rallback();
                else {
                    var backurl = $(".hd_backurl").val();
                    if (backurl != null && backurl != "")
                        location.href = backurl;
                    else
                        location.reload();
                }
            } else {
                $.alert(data, "error");
                btnopen(dom, "登录");
            }
        });
    }
}

//定位光标到最后
var setpos = function (o) {
    if (o.setSelectionRange) {
        setTimeout(function () {
            o.setSelectionRange(o.value.length, o.value.length);
            o.focus()
        }, 0)
    } else if (o.createTextRange) {
        var textrange = o.createTextRange();
        textrange.moveStart("character", o.value.length);
        textrange.moveEnd("character", 0);
        textrange.select();
    }
};

//在光标处插入内容
var innerCon = function (obj, str) {
    if (!obj.is(":focus"))
        obj.val(obj.val() + str);
    else {
        obj = obj[0];
        if (document.selection) {
            var sel = document.selection.createRange();
            sel.text = str;
        } else if (typeof obj.selectionStart === 'number' && typeof obj.selectionEnd === 'number') {
            var startPos = obj.selectionStart,
                endPos = obj.selectionEnd,
                cursorPos = startPos,
                tmpStr = obj.value;
            obj.value = tmpStr.substring(0, startPos) + str + tmpStr.substring(endPos, tmpStr.length);
            cursorPos += str.length;
            obj.selectionStart = obj.selectionEnd = cursorPos;
        } else {
            obj.value += str;
        }
    }
}

//Guid
function guid() {
    return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
        var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
        return v.toString(16);
    });
}
/*
*自动补全
*/
function autosearch() {
    var oldtxt;
    $(document).on("keyup", ".autocomplete", function () {
        if ($(this).val() == oldtxt) return;
        var top = $(this).offset().top;
        var left = $(this).offset().left;
        var height = $(this).height();
        var width = $(this).width();
        var key = $(this).val();
        var auto = $(this).attr("data-auto");
        var this_0 = this;
        oldtxt = key;
        $(".autolist").remove();

        if (key.length >= 1) {
            var html = '<div style="top:' + (top + height + 2) + 'px;left:' + left + 'px;width:' + width + 'px" class="autolist shadow">';
            if (auto == "user") {
                $.ajax({
                    type: "post",
                    async: true,
                    url: "/Comm/user.ashx",
                    data: { action: "UserListForKey", key: key },
                    success: function (data) {
                        if (data != null && data != "") {
                            html += data + "</div>";
                            $(document.body).append(html);

                            $(".autolist a").click(function () {
                                $(this_0).val($(this).html());
                                $(".autolist").remove();
                            });
                        }
                    }
                });
            }
            else if (auto == "store") {
                $.ajax({
                    type: "post",
                    async: true,
                    url: "/Comm/user.ashx",
                    data: { action: "ShopUserKey", key: key },
                    success: function (data) {
                        if (data != null && data != "") {
                            html += data + "</div>";
                            $(document.body).append(html);

                            $(".autolist a").click(function () {
                                $(this_0).val($(this).html());
                                $(".autolist").remove();
                            });
                        }
                    }
                });
            }
        }
    }).blur(function () {
        if ($(".autolist").length == 0 || !$(".autolist").is(":hover")) {
            $(".autolist").remove(); oldtxt = "";
        }
    });
}

function closeAlert() {
    $("#showAlert").remove();
    $(".showAlert_bg").remove();
}
/** 
* @重写Alert与Confirm
*/
(function ($) {
    $.extend({
        alert: function (html, type) {
            var dialog = new Dialog();

            if (type == "warn")
                html = "<i class=\"warn\"></i><span class=\"text\">" + html + "</span>";
            else if (type == "right")
                html = "<i class=\"right\"></i><span class=\"text\">" + html + "</span>";
            else if (type == "error")
                html = "<i class=\"error\"></i><span class=\"text\">" + html + "</span>";

            dialog.build('alert', null, null, html);
        },
        confirm: function (html, callback, cancel_callback) {
            var dialog = new Dialog();
            dialog.build('confirm', callback, cancel_callback, html);
        }
    });
    var time_ooooo = null;
    var Dialog = function () {
        var render = {
            template: '<div id="showAlert" class="shadow bora"><p class="alertHtml"></p></div>',
            templateConfirm: '<div id="showAlert" class="shadow bora"><p class="alertHtml"></p><p class="btn"><a class="btn_red alert_ok" id="sure">确定</a><a class="btn_gray alert_cancel" id="cancel">取消</a></p></div>',
            bg_box: '<div class=\"showAlert_bg\"></div>',
            /** 
            * 根据需要生成对话框 
            * @param {Object} type 
            * @param {Object} callback 
            * @param {Object} html 
            */
            renderDialog: function (type, callback, cancel_callback, html) {
                if (type == 'alert') {
                    this.renderAlert(callback, html);
                } else {
                    this.renderConfirm(callback, cancel_callback, html);
                }
            },
            /** 
            * 生成alert 
            * @param {Object} callback 
            * @param {Object} html 
            */
            renderAlert: function (callback, html) {
                $('div#showAlert').remove(); //清除原有的
                clearTimeout(time_ooooo);
                var temp = $(this.template).clone().hide();
                temp.find('p.alertHtml').html(html);
                $(document.body).append(temp);
                this.setPosition(temp);
                temp.fadeIn();
                this.bindEvents('alert', temp, callback);
            },
            /** 
            * 生成confirm 
            * @param {Object} callback 
            * @param {Object} html 
            */
            renderConfirm: function (callback, cancel_callback, html) {
                $('div#showAlert').remove(); //清除原有的
                $(".showAlert_bg").remove();
                clearTimeout(time_ooooo);
                var temp = $(this.templateConfirm).clone().hide();
                temp.find('p.alertHtml').html(html);
                $(document.body).append(temp);
                $(document.body).append(this.bg_box);
                this.setPosition(temp);
                temp.fadeIn();
                this.bindEvents('confirm', temp, callback, cancel_callback);
            },
            /** 
            * 设定对话框的位置 
            * @param {Object} el 
            */
            setPosition: function (el) {
                var width = el.width() + 120,
                    height = el.height() + 40,
                    pageSize = this.getPageSize();
                el.css({
                    top: (pageSize.h - height) / 2,
                    left: (pageSize.w - width) / 2
                });
            },
            /** 
            * 绑定事件 
            * @param {Object} type 
            * @param {Object} el 
            * @param {Object} callback 
            */
            bindEvents: function (type, el, callback, cancel_callback) {
                if (type == "alert") {
                    time_ooooo = setTimeout(function () { $('div#showAlert').fadeOut(function () { $('div#showAlert').remove() }) }, 3000);
                } else {
                    if ($.isFunction(callback)) {
                        $('#sure').click(function () {
                            $('div#showAlert').remove();
                            $(".showAlert_bg").remove();
                            callback();
                        });
                    } else {
                        $('#sure').click(function () {
                            $('div#showAlert').remove();
                            $(".showAlert_bg").remove();
                        });
                    }
                    $('#cancel').click(function () {
                        $('div#showAlert').remove();
                        $(".showAlert_bg").remove();
                        if (cancel_callback != null && $.isFunction(cancel_callback))
                            cancel_callback();
                    });
                }
            },
            /** 
            * 获取页面尺寸 
            */
            getPageSize: function () {
                return {
                    w: document.documentElement.clientWidth,
                    h: document.documentElement.clientHeight
                }
            }
        }
        return {
            build: function (type, callback, cancel_callback, html) {
                render.renderDialog(type, callback, cancel_callback, html);
            }
        }
    }
})(jQuery);
